#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int t,ans[15];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n;
        scanf("%d",&n);
        int m[200010],y[1000010],maxn=-1,cnt=0;
        for(int j=1;j<=n;j++) 
        {
            scanf("%d",&m[i]);
            y[m[i]]++;
            maxn=max(maxn,m[i]);
        }
        for(int j=1;j<=maxn;j++)
        {
            if(y[j]>0) cnt+=y[j]-1;
        }
        ans[i]=cnt;
    }for(int i=1;i<=t;i++) printf("%d\n",ans[i]);
    fclose(stdin);
    fclose(stdout);
    return 0;
}